//
//  ButtonView.m
//  PlayADS
//
//  Created by 周莹 on 15/12/21.
//  Copyright © 2015年 周莹. All rights reserved.
//
#import "Colours.h"
#import "ButtonView.h"
#define Phight   [UIScreen mainScreen].bounds.size.height
#define Pwidth    [UIScreen  mainScreen].bounds.size.width
#define y    15
#define zwith  70
#define Zhight 35

// 屏幕_宽_高
#define SCREEN_WIDTH  ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT  ([[UIScreen mainScreen] bounds].size.height)

#define IPHONE6_W 375.0f
#define IPHONE6_H 667.0f

// 控件缩放比例
#define SCALE_WIDTH(w) (SCREEN_WIDTH/375.0*w)

// 如果是iPhone4
#define RECTFIX_WIDTH(a) (IS_IPHONE4 ? a : SCALE_WIDTH(a))
#define RECTFIX_HEIGHT(a) (IS_IPHONE4 ? a : SCALE_HEIGHT(a))

// 左右两边的间距
#define MARGIN_1 10.0f

// 男女之间的间距
#define MARGIN_2 5.0f

// 第一个按钮的宽
#define BUTTON_1_W 95.0f

// 按钮的高
#define BUTTON_H 30.0f

// 按钮的Y值
#define BUTTON_Y 30.0f

@implementation ButtonView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor greenColor];
      
        //        [self calculateHeightWithString:self.activity.address];
    }
    return self;
}

-(instancetype)initWithFrame:(CGRect)frame  withTextLabel:(NSString*)textLabel1 withTextLabel:(NSString*)textLabel2 withTextLabel:(NSString*)textLabel3 withTextLabel:(NSString*)textLabel4{

    self = [super initWithFrame:frame];
    if (self)
    {
   
    //self.button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [self.button1  setTitle:textLabel1 forState:UIControlStateNormal];
        
        [self.button1 setTitleColor:[UIColor  blackColor] forState:UIControlStateNormal];
    self.button1.backgroundColor = [UIColor  greenColor];
    
    [self  addSubview:self.button1];
    
    
    
    //self.button2 = [[UIButton  alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.button1.frame )+10, y, zwith, Zhight)];
    //[self.button2 setTitle:@"男" forState:UIControlStateNormal];
    [self.button2 setTitle:textLabel2 forState:UIControlStateNormal];
    
    self.button2.backgroundColor = [UIColor  blueColor];
    
    
    [self  addSubview:self.button2];
    
    
    
    
    
    

   // self.button3 = [[UIButton  alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.button2.frame )+10, y, zwith, Zhight)];
   [self.button3  setTitle:textLabel3 forState:UIControlStateNormal];
        self.button3.backgroundColor = [UIColor  blueColor];
    
    [self  addSubview:self.button3];
    
        
        
        
        
        

    //self.button4 = [[UIButton  alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.button3.frame )+10, y, zwith, Zhight)];
        
           [self.button4  setTitle:textLabel4 forState:UIControlStateNormal];
        self.button4.backgroundColor = [UIColor  blueColor];
    
    
    [self  addSubview:self.button4];
   
        
        
        
        
        //button1
        CGFloat btn1W = SCALE_WIDTH(BUTTON_1_W);
        CGFloat btn1H = SCALE_WIDTH(BUTTON_H);
        CGFloat btn1X = MARGIN_1;
        CGFloat btn1Y = BUTTON_Y;
        
        self.button1.frame = CGRectMake(btn1X, btn1Y, btn1W, btn1H);
        
        
        
        
        //button2
        
        CGFloat w = (SCREEN_WIDTH - (MARGIN_1 * 2) - (MARGIN_2 * 3) - btn1W) / 3;
        
        CGFloat btn2W = w;
        CGFloat btn2H = btn1H;
        CGFloat btn2X = CGRectGetMaxX(self.button1.frame) + MARGIN_2;
        CGFloat btn2Y = BUTTON_Y;
        
        self.button2.frame = CGRectMake(btn2X, btn2Y, btn2W, btn2H);
        
        
        
        
        //button3
        
        CGFloat btn3W = w;
        CGFloat btn3H = btn1H;
        CGFloat btn3X = CGRectGetMaxX(self.button2.frame) + MARGIN_2;
        CGFloat btn3Y = BUTTON_Y;
        
        self.button3.frame = CGRectMake(btn3X, btn3Y, btn3W, btn3H);
        
        
        
        
        //button4
        CGFloat btn4W = w;
        CGFloat btn4H = btn1H;
        CGFloat btn4X = CGRectGetMaxX(self.button3.frame) + MARGIN_2;
        CGFloat btn4Y = BUTTON_Y;
        
        self.button4.frame = CGRectMake(btn4X, btn4Y, btn4W, btn4H);
        
   
    
}


    return self;
}





@end
